<template>
  <div>
    <xy-table
      ref="xy-table"
      :columns="columns"
      :api="api"
      :param="form"
      :addFormDTO="addForm"
      :on-edit="editItem"
    >
      <template slot="addItem">
        <search-header :model="form" :on-search="onSearch" keywords="业务单号">
          <template v-if="user.roletype == 99 || user.roletype == 6" #add-btn>
            <el-button icon="el-icon-plus" @click="toPayDetail" size="mini"
              >{{ $language.local("Recharge") }}
            </el-button>
          </template>
        </search-header>
      </template>
      <template #edit="{ row }">
        <span v-if="row.RechargeStatus > 0" hidden></span>
      </template>
      <template #check="{ row }">
        <span v-if="row.RechargeStatus == 3" hidden></span>
        <el-button v-else type="text" @click="onCheck(row)">审核</el-button>
      </template>
    </xy-table>
  </div>
</template>

<script>
import API from "../../plugins/api";

export default {
  name: "payroll",

  data() {
    return {
      param: {},
      ServiceID: 123,
      api: new API("/api/recharge/"),
      columns: {
        BusinessOrderNo: "",
        CustomerName: 127,
        // BusinessOrderNo: "B20210602165304",
        ServiceProviderName: "湖南好捷科技有限公司",
        //  Indate: "2021-06-02T16:54:05.673",
        RechargeTime: "2021-06-02T16:53:04",
        RechargeAmount: 100,
        ruleType: "",
        RechargeStatus: 2,
      },
      addForm: {
        // _serviceproviderid: null,
        ServiceProviderName: "",
        ServiceBank: "",
        // ServiceBankId: null,
        ServiceAccountNo: "",
        PayChannelId: "",

        // MID: "客户",
        CustomerName: "",
        // _agentname: "客户名称",
        ruleType: "",
        RechargeRate: "",
        RechargeTime: "",
        RechargeAmount: "",
        // _rechargetime: "充值时间",
        AccountAmount: "",
        PayingAccountName: "",
        PayingBank: "",
        PayingAccount: "",
        Note: "",
        // RechargeStatus: "充值状态",
      },
      services: [],
      form: {
        SID: "",
        BeginDate: new Date(new Date() - 3600 * 1000 * 24 * 30).format(
          "yyyy-MM-dd"
        ),
        EndDate: new Date().format("yyyy-MM-dd"),
        RechargeStatus: "",
      },
      user: this.$store.getters.user,
    };
  },
  created() {
    let { menus } = this.$store.getters.data;
    console.log(menus);
  },
  methods: {
    onSearch(e) {
      // this.param.BeginDate = this.param.date[0].toLocaleDateString();
      // this.param.EndDate = this.param.date[1].toLocaleDateString();
      console.log(e);
      this.$refs["xy-table"].getData(e);
    },
    beginDateChange(value, row, column) {
      console.log(value, row, column);
    },
    statusChange(value, row, column) {
      console.log(value, row, column);
    },

    toPayDetail() {
      // this.$store.commit("setData", { [this.api.entity]: this.addForm });
      this.$router.push({
        name: "立即充值",
        params: { apiName: this.api.create },
      });
    },
    onCheck(row) {
      console.log(row);
      this.$router.push({
        name: "立即充值",
        params: { row, apiName: this.api.check },
      });
    },
    editItem(row) {
      console.log(row);
      // this.$store.commit("setData", { [this.api.entity]: row });
      this.$router.push({
        name: "立即充值",
        params: { row, apiName: this.api.edit },
      });
    },
  },
};
</script>

<style lang="less" scoped>
.label {
  height: 100%;
}
.line {
  display: flex;
  justify-content: center;
  align-items: center;
}
.el-form {
  display: flex;
  justify-content: flex-start;
  .el-form-item {
    flex: 3;
    &.btn {
      flex: 1;
    }
  }
}
</style>
